# -*- coding:utf-8 -*-
# # 使用面向对象的方式写多线程，需要继承threading下面的Thread类
from threading import Thread
import time


class Thread_one(Thread):
    def __init__(self, name, age):
        super().__init__()          # super() 查找父类里的属性或方法
        self.name = name
        self.age = age

    # 子线程执行的任务，写在run方法里面
    def run(self):                        # 这个名字必须是run
        for num in range(5):
            print(f"大家好，我是{self.name}, 我今年{self.age}岁了")
            time.sleep(1)


class Thread_two(Thread):
    def __init__(self, name, age):
        super().__init__()        # super() 查找父类里的属性或方法
        self.name = name
        self.age = age

    def run(self):  # 这个名字必须是run
        for num in range(5):
            print(f"大家好，我是{self.name}, 我今年{self.age}岁了")
            time.sleep(1)


def main():
    t1 = Thread_one("张三", 18)
    t1.start()
    t2 = Thread_two("李四", 25)
    t2.start()


if __name__ == '__main__':
    main()
